package reader;


import javafx.fxml.FXML;
import javafx.scene.control.Button;

public class CashDispenser extends Button {
	private Button cashDispense;
	private double cash;

	public CashDispenser(double cash) {
		super();
		this.cash = cash;
	}

	public double getCash(){
		return cash;
	}

	/* 吐钞
	 * @see domain.CashDispenser#spitOutCash(double)
	 */

	public void dispenseCash(double amount) {
		if(cash >= amount){
			this.cash =this.cash-amount;
		}else {
			this.setDisable(false);
			this.setText("钱箱没钱了！");
			System.out.println("钱箱没钱了！");
		}
		this.setDisable(true);; //模拟吐钞口打开
		this.setText(amount + "");//模拟吐钞
	}

	/* 关闭吐钞出口。模拟现金被取走
	 * @see domain.CashDispenser#closeDispenser()
	 */
	public void closeDispenser() {
		this.setDisable(false);
		this.setText("");
	}
}
